

**********************************************************************************************************************
**** Table 5. Treatment Effects of Basic Treatment in Comparison to Untreated Group **********************************
**********************************************************************************************************************


use "$data/Non_payment_dataset_ready.dta" , clear

log using "$filepath/output_logs/table 5", replace


gen ebalancematch=0 if itt==.
replace ebalancematch=1 if itt==0

**** Ebalance matching ****
ebalance ebalancematch meanasinhinvoice inactive prenoconsumption paidcount1 paidcount2 meanaveragepayment1 meanaveragepayment2 preclosingbalancew preage_of_accountw presumpaymentratiow if t==12, target(2)
bysort customer: egen entropy_weight=mean(_webal)

*********************************
**** Initial month (October) ****
*********************************

probit paidcount ebalancematch [pweight=entropy_weight] if t==14 ,vce(cluster customer)
margins, dydx(*) post

reg lnpayment ebalancematch [pweight=entropy_weight] if t==14, vce(cluster customer)

preserve 
keep if t==14
capture program drop Ey_boot
program define Ey_boot, eclass
twopm payment ebalancematch [pweight=entropy_weight], firstpart(probit) secondpart(regress, log) vce(cluster customer)
margins, dydx(ebalancematch) predict(duan) nose post
end
bootstrap _b, seed(3125) reps(1000): Ey_boot
restore


reg asinhpayment ebalancematch [pweight=entropy_weight] if t==14, vce(cluster customer)


*************************************
**** Medium term (November-June) ****
*************************************
probit paidcount ebalancematch [pweight=entropy_weight] if t>=15 & t<=22 ,vce(cluster customer)
margins, dydx(*) post

reg lnpayment ebalancematch  [pweight=entropy_weight] if t>=15 & t<=22 , vce(cluster customer)

preserve 
keep if t>=15 & t<=22 
capture program drop Ey_boot
program define Ey_boot, eclass
twopm payment ebalancematch  [pweight=entropy_weight], firstpart(probit) secondpart(regress, log) vce(cluster customer)
margins, dydx(ebalancematch) predict(duan) nose post
end
bootstrap _b, seed(3125) reps(1000): Ey_boot
restore

reg asinhpayment ebalancematch [pweight=entropy_weight] if t>=15 & t<=22, vce(cluster customer)


** Control means ***
estpost tabstat paidcount lnpayment payment asinhpayment [aweight=entropy_weight] if t==14, by(ebalancematch) statistics(mean sd n) columns(statistics) nototal
estpost tabstat paidcount lnpayment payment asinhpayment [aweight=entropy_weight] if t>=15 & t<=22, by(ebalancematch) statistics(mean sd n) columns(statistics) nototal

log close
